package com.cobra.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}

//key-value类型 partitionby
object Spark22_RDD_Operator_Transform_groupByKey {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Spark21_RDD_Operator_Transform_reduceByKey$")
    val sc = new SparkContext(sparkConf)
   val rdd = sc.makeRDD(List(
     ("a",1),("a",2),("a",3),("b",4)
   ))
    //元素的第一个是key，第二个是key的value的集合
    rdd.groupByKey().collect().foreach(println)
    sc.stop()
  }
}
